***********###########Great Power Shocks and the Dynamics of Secession###########***********
/////Replication Code/////

///relogit package is necessary; type "ssc install relogit"///
///analysis run using Stata 17///

***[1] MOVEMENT Onset***
**1) System-Year Level Analysis (DV: counter of the onset of secessionist movement)**[use System Years_II_Final.dta]
*Check for overdispersion
poisson countonset hshock nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)

estat gof

//data are overdispersed; nbreg is a better estimator choice

//shock years and # of new secessionist movements
nbreg countonset hshock nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset hshock statenum nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset hshock total nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)

**calculate the marginal effect of the hegemonic shock variable**
margins, dydx(hshock)
sum countonset if e(sample)

//appendix only: four-years span as an alternative IV
nbreg countonset hshock4 nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset hshock4 statenum nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset hshock4 total nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)

//appendix only: five-years span as an alternative IV
nbreg countonset hshock5 nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset hshock5 statenum nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset hshock5 total nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)

//appendix only: using disaggregated shock variables
nbreg countonset ww1hshock ww2hshock cwhshock nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset ww1hshock ww2hshock cwhshock statenum nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset ww1hshock ww2hshock cwhshock total nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)

//appendix only: using the average hegemonic volatility scores
nbreg countonset ahvscore nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset ahvscore statenum nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)
nbreg countonset ahvscore total nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, vce(robust)


**2) Country-Year Level Analysis (DV: the onset of any secessionist movement)**[use Country Year_II_Final.dta]
relogit onsetbinary hshock nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary hshock polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary hshock polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012 & USSRcwonly==0, cluster(ccode)

//appendix only: four-years span as an alternative IV
relogit onsetbinary hshock4 nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary hshock4 polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary hshock4 polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012 & USSRcwonly4==0, cluster(ccode)

//appendix only: five-years span as an alternative IV
relogit onsetbinary hshock5 nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary hshock5 polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary hshock5 polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012 & USSRcwonly5==0, cluster(ccode)

//appendix only: additional controls (ELF and shock losers)
gen loser_shock = 0
replace loser_shock = 1 if ww1hshock==1 & ccode==365
replace loser_shock = 1 if ww1hshock==1 & ccode==255
replace loser_shock = 1 if ww1hshock==1 & ccode==300
replace loser_shock = 1 if ww1hshock==1 & ccode==305

replace loser_shock = 1 if ww2hshock==1 & ccode==255
replace loser_shock = 1 if ww2hshock==1 & ccode==325
replace loser_shock = 1 if ww2hshock==1 & ccode==740

replace loser_shock = 1 if cwhshock==1 & ccode==365

relogit onsetbinary hshock polity2 recent concur elf nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary hshock polity2 recent concur loser_shock nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)

**calculate the marginal effect of the hegemonic shock variable (model 5)**
set seed 20000
setx mean
relogitq, fd(pr) changex(hshock 0 1)

**calculate the marginal effect of the concurrent movement variable (model 5)**
set seed 20000
setx mean
relogitq, fd(pr) changex(concur 0 1)
relogitq, fd(pr) changex(concur 0 2)
relogitq, fd(pr) changex(concur 0 3)

**difference of mean test for the concurrent movement variable (model 5)**
ttest concur if e(sample), by(hshock)

//appendix only: country fixed effects
xtlogit onsetbinary hshock polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, fe

//appendix only: using the average hegemonic volatility scores
relogit onsetbinary ahvscore nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary ahvscore polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary ahvscore polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012 & USSRcwonly==0, cluster(ccode)

//appendix only: using disaggregated shock variables
relogit onsetbinary ww1hshock ww2hshock cwhshock nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary ww1hshock ww2hshock cwhshock polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(ccode)
relogit onsetbinary ww1hshock ww2hshock cwhshock polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012 & USSRcwonly==0, cluster(ccode)

//appendix only: clustering SE at the year level
relogit onsetbinary hshock nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(year)
relogit onsetbinary hshock polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012, cluster(year)
relogit onsetbinary hshock polity2 recent concur nosecessionyrs nosecessionyrs2 nosecessionyrs3 if year>=1900 & year<2012 & USSRcwonly==0, cluster(year)


***[2] MOVEMENT OUTCOMES***
**1) Movement Level Analysis (DV: metropoles' initial response)**[use Movement Years_II_Final.dta]
logit response1 hshock if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 hshock polity2new if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 hshock polity2new recent concur if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 hshock polity2new recent concur if start~=. & year>=1900 & year<2012 & USSRcwonly==0, vce(robust)

**difference of means test (model 9)**
ttest response1 if e(sample), by(hshock)

//appendix only: using disaggregated shock variables
logit response1 ww1hshock ww2hshock cwhshock if start~=.& year>=1900 & year<2012, vce(robust)
logit response1 ww1hshock ww2hshock cwhshock polity2new if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 ww1hshock ww2hshock cwhshock polity2new recent concur if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 ww1hshock ww2hshock cwhshock polity2new recent concur if start~=. & year>=1900 & year<2012 & USSRcwonly==0, vce(robust)

//appendix only: four-years span as an alternative IV
logit response1 hshock4 if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 hshock4 polity2new if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 hshock4 polity2new recent concur if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 hshock4 polity2new recent concur if start~=. & year>=1900 & year<2012 & USSRcwonly4==0, vce(robust)

//appendix only: five-years span as an alternative IV
logit response1 hshock5 if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 hshock5 polity2new if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 hshock5 polity2new recent concur if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 hshock5 polity2new recent concur if start~=. & year>=1900 & year<2012 & USSRcwonly5==0, vce(robust)

//appendix only: using the average hegemonic volatility scores
logit response1 ahvscore if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 ahvscore polity2new if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 ahvscore polity2new recent concur if start~=. & year>=1900 & year<2012, vce(robust)
logit response1 ahvscore polity2new recent concur if start~=. & year>=1900 & year<2012 & USSRcwonly==0, vce(robust)
